Store Script
The Store Script command stores a specified script object in a specified file. It is the only command provided by the Store Script scripting addition.SYNTAX
store script scriptObjectVariable ¬ [in referenceToFile ] ¬ [ replacing replacementOption ]PARAMETERS
- scriptObjectVariable
- The name of a script object declared previously in the
same script.
Class: Script
- referenceToFile
- A reference of the form
file
nameString oralias
nameString (see "Notes"). If this parameter is omitted, Store Script displays a directory dialog box and requests that the user choose a file in which to store the script.
Class: Reference
- replacementOption
- One of the constants
ask
,yes
, orno
. The constantask
causes the Store Script command to display a dialog box asking the user whether to overwrite the file specified by scriptObjectVariable, rename it, or cancel the operation. (Displaying this dialog box is the default if thereplacing
parameter is omitted.) The constantyes
indicates that you want Store Script to replace the file, and the constantno
indicates that you do not want Store Script to replace the file if it already exists.
Class: StringRESULT
NoneEXAMPLES
This script object is used in the examples that follow:
script DemoStore property Red: 127 property Green : 128 property Blue : 127 on returnRGB() return Red & Green & Blue end return end scriptThis example stores the script object DemoStore in a file called Store My RGB:
store script DemoStore in file ¬ "My HD:Some Folder:Store My RGB" replacing yesThereplacing yes
parameter indicates that Store Script should overwrite the existing file.Later statements in the same script like the following load the stored script object
DemoStore
, change one of its properties, and store it to disk again:
set objRef to load script ¬ file "My HD:Some Folder:Store My RGB" set objRef's Red to 250 store script objRef ¬ in file "My HD:Some Folder:Store My RGB"In this case thereplacing
parameter is omitted, so Store Script displays a dialog box asking the user whether to overwrite the file, rename it, or cancel the operation.NOTES
To specify the name (nameString) of a file, use a string of the form"Disk:Folder1:
as described in Chapter 5, "Objects and References,"
Folder2:...:Filename"
of the AppleScript Language Guide. If you specify only the name of the file (Filename) instead of its entire pathname, AppleScript attempts to find the file in the current directory.ERRORS